package com.tiance.demo.service.mysql.constants;

import java.util.HashMap;
import java.util.Map;

public class FilePageType {

    //	最新分配，还没使用
    public static final int FIL_PAGE_TYPE_ALLOCATED = 0x0000;
    //	Undo日志页********************
    public static final int FIL_PAGE_UNDO_LOG = 0x0002;
    //	段信息节点
    public static final int FIL_PAGE_INODE = 0x0003;
    //	Insert Buffer空闲列表
    public static final int FIL_PAGE_IBUF_FREE_LIST = 0x0004;
    //	Insert Buffer位图
    public static final int FIL_PAGE_IBUF_BITMAP = 0x0005;
    //	系统页
    public static final int FIL_PAGE_TYPE_SYS = 0x0006;
    //  事务系统数据
    public static final int FIL_PAGE_TYPE_TRX_SYS = 0x0007;
    //	表空间头部信息************************
    public static final int FIL_PAGE_TYPE_FSP_HDR = 0x0008;
    //  扩展描述页
    public static final int FIL_PAGE_TYPE_XDES = 0x0009;
    //	溢出页
    public static final int FIL_PAGE_TYPE_BLOB = 0x000A;
    //	索引页，也就是我们所说的数据页
    public static final int FIL_PAGE_RTREE = 0x45BE;
    //	索引页，也就是我们所说的数据页
    public static final int FIL_PAGE_INDEX = 0x45BF;

    private static final Map<Integer, String> PAGE_TYPE_NAMES = new HashMap<>();

    static {
        PAGE_TYPE_NAMES.put(FIL_PAGE_RTREE, "索引页RTREE");
        PAGE_TYPE_NAMES.put(FIL_PAGE_INDEX, "索引页");
        PAGE_TYPE_NAMES.put(FIL_PAGE_TYPE_SYS, "系统页");
        PAGE_TYPE_NAMES.put(FIL_PAGE_INODE, "段信息节点");
        PAGE_TYPE_NAMES.put(FIL_PAGE_UNDO_LOG, "Undo日志页");
        PAGE_TYPE_NAMES.put(FIL_PAGE_TYPE_XDES, "扩展描述页");
        PAGE_TYPE_NAMES.put(FIL_PAGE_TYPE_BLOB, "溢出页");
        PAGE_TYPE_NAMES.put(FIL_PAGE_TYPE_ALLOCATED, "尚未使用");
        PAGE_TYPE_NAMES.put(FIL_PAGE_IBUF_FREE_LIST, "Insert Buffer空闲列表");
        PAGE_TYPE_NAMES.put(FIL_PAGE_IBUF_BITMAP, "Insert Buffer位图");
        PAGE_TYPE_NAMES.put(FIL_PAGE_TYPE_TRX_SYS, "事务系统数据");
        PAGE_TYPE_NAMES.put(FIL_PAGE_TYPE_FSP_HDR, "表空间头部信息");
    }

    public static String getTypeName(Integer type) {
        String typeName = PAGE_TYPE_NAMES.get(type);
        return typeName== null ? String.valueOf(type): typeName;
    }
}
